
	'
	'  Adler-32 checksum algorithm (http://en.wikipedia.org/wiki/Adler-32)
	'
	Function Adler32(ptrData As UByte Pointer, length As Integer) As UInteger
		
		Dim As UInteger	a = 1, b = 0
				
		While length > 0
			
			Dim As UInteger tlen = IIf(length > 5550, 5550, length)
			
			length -= tlen
			
			Do
				
				a += *ptrData
				ptrData += 1
				
				b += a
				
				tlen -= 1
				
			Loop While tlen > 0
			
			a Mod= 65521
			b Mod= 65521

		Wend
		
		Return (b Shl 16) Or a
 
	End Function
	
	
	'
	'  Paul Hsieh's SuperFastHash
	'  http://www.azillionmonkeys.com/qed/hash.html
	'   
	Function SuperFastHash(ptrData As UByte Pointer, length As Integer) As UInteger
	
		#Define get16bits(d) ((Cast(Uinteger, Cast(Ubyte Ptr, d)[1]) Shl 8) + Cast(Uinteger, Cast(Ubyte Ptr, d)[0]))
		
		Dim As Uinteger hash = length, tmp
		Dim As Integer r
		
		If length = 0 Then Return 0
		
		r = length And 3
		length Shr= 2
		
		Do While length > 0
		 
			hash    += get16bits(ptrData)
			tmp      = (get16bits(ptrData + 2) Shl 11) Xor hash
			hash     = (hash Shl 16) Xor tmp
			ptrData += 2 * SizeOf(UShort)
			hash    += hash Shr 11
			
			length -= 1
		  
		Loop
		
		Select Case r
		 
			Case 3
				hash += get16bits(ptrData)
				hash Xor= hash Shr 16
				hash Xor= ptrData[SizeOf(UShort)] Shl 18
				hash += hash Shr 11
			  
			Case 2
			   hash += get16bits(ptrData)
			   hash Xor= hash Shl 11
			   hash += hash Shr 17
			  
			Case 1
			   hash += *ptrData
			   hash Xor= hash Shl 10
			   hash += hash Shr 1
			  
		End Select
	   
		hash Xor= hash Shl 3
		hash +=   hash Shr 5
		hash Xor= hash Shl 4
		hash +=   hash Shr 17
		hash Xor= hash Shl 25
		hash +=   hash Shr 6
		
		Return hash
		
		#Undef get16bits
	       
	End Function